package com.apply.config;

import java.util.HashMap;

/**
 * @author tianp
 */
public class Results extends HashMap<String, Object> {
    private static int CODE = 500;
    private static String MSG = "error";

    public static Results success() {
        return success(200, null);
    }

    public static Results success(Object data) {
        Results results = new Results();
        results.put("code", 200);
        results.put("data", data);
        return results;
    }

    public static Results success(int code, Object data) {
        Results results = new Results();
        results.put("code", code);
        results.put("data", data);
        return results;
    }

    public static Results error() {
        return error(CODE, MSG);
    }

    public static Results error(String msg) {
        Results results = new Results();
        results.put("code", CODE);
        results.put("msg", msg);
        return results;
    }

    public static Results error(int code, String msg) {
        Results results = new Results();
        results.put("code", code);
        results.put("msg", msg);
        return results;
    }
}
